/**
 * 公用参数
 */
var hospName='',//医院名称
    timeName='',//采样时间
	sortName='', //选择顺序
	name='',//病人姓名
    type='jy'
var cardInfo=null
var makeInfo={}

/**
 * 默认加载
 * @type {{init: Window.process.init, public: Window.process.public}}
 */
window.process = {
    init: function () {
        this.initData();
        this.public();
    },
    initData:function () {
        var paramsData = getUrlParamsCode();
        name= paramsData['name'];
        cardInfo=JSON.parse(localStorage.getItem('cardInfo'))
        if(!!name){
            name=cardInfo.username
        }
        this.load(type)

    },
    load(type){
        if(type=='jy'){
            var api='/appReportlabs/find'
        }else{
            var api='/appReportexams/find'
        }
        var data={
            hoscode:!!cardInfo?cardInfo.hostcode:'',
			patientname:name,
            idcard:!!cardInfo?cardInfo.idcard:'',
			phone:!!cardInfo?cardInfo.phone:'',
			cardno:!!cardInfo?cardInfo.cardno:'',
            cardtype:!!cardInfo?cardInfo.cardtype:'',
            reporttype:type

        }
        postAjax(api,data,this.callbackLoad,this)
    },
    callbackLoad(data,that){
        makeInfo=data
        var Data={
            list:data
        };
        var listHtml = template('list_data', Data);
        $("#list_data_content").html(listHtml);
        that.public();
    },
    public: function () {
        var that=this
        //进入搜索
        $('#person').click(function () {
            window.location.href='visiter.html?current=report'
        });
        
        //进入详情
        $('#list_data_content .item').click(function () {
            var key=$(this).attr('data-key')
            localStorage.setItem("reportInfo", JSON.stringify(makeInfo[key]));
            window.location.href="report_detail.html";

        })
		
		//选择类型
       $('#handleHosp').click(function () {
		   $('#dataSel').hide();
           $('#hospAll').show();
		   
        })
		
		//选择日期
		$('#handleData').click(function () {
		   $('#hospAll').hide();	
           $('#dataSel').show();
		   
        })
		
		//选择类型
		$('.hospAll li').click(function(){
			that.load($(this).attr('data-id'))
		})
		
		//选择日期内容
		$('.dataSel #time li').click(function(e){
			e.stopPropagation();
			$(this).addClass('on').siblings().removeClass('on');
			timeName=$(this).text();
		})
		
		$('.dataSel #sort li').click(function(e){
			e.stopPropagation();
			$(this).addClass('on').siblings().removeClass('on');
			sortName=$(this).text();
		})
		
		//日期选择 确定
		$('.save').click(function(){
			
		})
		
		//选择空白关闭
		$('.topPon').click(function(){
		   $('.topPon').hide()	
		})
       

    }
};

/**
 * 启动方法执行
 */
process.init();



